<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>监管企业信息查询</title>
	<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
	<script type="text/javascript" src="easyui/jquery.min.js"></script>
	<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="监管企业信息查询" style="width:auto;height:auto"
			data-options="
				singleSelect: true,
				toolbar: '#tb',
				url: 'scztxx',
				method: 'get',
				toolbar:'#tb',
				rownumbers:true,
				pagination:true,
				pageSize:10
			">
		<thead>
			<tr>
				<th data-options="field:'id',width:120,hidden:true">ID</th>
				<th data-options="field:'uniscId',width:140,
						formatter:function(value,row){
							return row.productname;
						},
						editor:{
							type:'combobox',
							options:{
								valueField:'productid',
								textField:'productname',
								method:'get',
								url:'products.json',
								required:true
							}
						}">统一社会信用代码</th>
				<th data-options="field:'regNo',width:180,hidden:true,align:'right',editor:{type:'numberbox',options:{precision:1}}">营业执照注册号</th>
				<th data-options="field:'entName',width:260,align:'left',editor:'numberbox'">企业名称</th>
				<th data-options="field:'lerepName',width:80,editor:'textbox'">法人</th>
				<th data-options="field:'regAddr',width:500,align:'center',editor:'numberbox'">企业地址</th>
				<th data-options="field:'enttype',width:100,align:'center',editor:'numberbox'">企业类型</th>
				<th data-options="field:'areaCode',width:80,align:'center',editor:'numberbox'">地区编号</th>
				<th data-options="field:'updateTime',width:160,align:'center',editor:'numberbox'">更新时间</th>
				<th data-options="field:'bizOrg',width:120,align:'center',editor:'numberbox'">所属机构</th>
			</tr>
		</thead>
	</table>
	 <div id="tb" style="padding:5px;height:auto">
			<div style="margin-bottom:5px">
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">添加无证企业</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendx()">添加有证企业</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a>
				<!-- <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">修改</a> -->
				&nbsp;&nbsp;企业名称: <input class="easyui-textbox" style="width:180px" id="search">
				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" data-options="iconCls:'icon-search',plain:true" onclick="searchGep()">查询</a>
			</div>
		</div>
	<div id="win" class="easyui-dialog" title="添加无证企业信息"  style="width: 400px; padding: 10px 20px; height: 310px;"
     closed="true" buttons="#dlg-buttons">
 
    <form id="fm" method="post" action="" style="margin-top: 20px; margin-left: 20px;">
        <div class="fitem">
            <label>企业名称:</label>
            <input id="entName" style="" name="" class="easyui-textbox" data-options="required:true" />
        </div>
        <div class="fitem">
            <label>所属区域:</label>
            <input id="areaCode" name="" class="easyui-combobox" data-options="valueField:'areCode',textField:'areName',url:'getjson'"/>
            
        </div>
        <div class="fitem">
            <label>所在地址:</label>
            <input id="regAddr" name="" class="easyui-textbox" data-options="required:true"/>
        </div>
 
        <div class="fitem">
            <label>企业类型:</label>
            <input id="enttype" name="" class="easyui-combobox" data-options="valueField:'entCode',textField:'entName',url:'enttypejson'" />
        </div>
 
        <div class="fitem">
            <label>企业法人:</label>
            <input id="lerepName" name="" class="easyui-textbox"  />
        </div>
 
        <div class="fitem">
            <label>联系电话:</label>
            <input id="contTel" name="" class="easyui-textbox"  />
        </div>
        <!--直接写提交取消的事件不需要在js中绑定-->
        <div style="display: block;margin-top: 20px;text-align: center;" >
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-ok'" onclick="inserEntity()" style="width: 90px">提交</a>
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#win').dialog('close')" style="width: 90px">取消</a>
        </div>
    </form>
    </div>
    
    <div id="winx" class="easyui-dialog" title="修改企业信息"  style="width: 400px; padding: 10px 20px; height: 380px;"
     closed="true" buttons="#dlg-buttons">
 
    <form id="fmx" method="post" action="" style="margin-top: 20px; margin-left: 20px;">
        <div class="fitem">
            <label>企业名称:</label>
            <input id="entNamex" style="" name="" class="easyui-textbox" data-options="required:true" />
        </div>
        <div class="fitem">
            <label>所属区域:</label>
            <input id="areaCodex" name="" class="easyui-combobox" data-options="valueField:'areCode',textField:'areName',url:'getjson'"/>
        </div>
        <div class="fitem">
            <label>所在地址:</label>
            <input id="regAddrx" name="" class="easyui-textbox" data-options="required:true"/>
        </div>
 
        <div class="fitem">
            <label>企业类型:</label>
            <input id="enttypex" name="" class="easyui-combobox" data-options="valueField:'entCode',textField:'entName',url:'enttypejson'" />
        </div>
 
        <div class="fitem">
            <label>企业法人:</label>
            <input id="lerepNamex" name="" class="easyui-textbox"  />
        </div>
 
        <div class="fitem">
            <label>联系电话:</label>
            <input id="contTelx" name="" class="easyui-textbox"  />
        </div>
        
        <div class="fitem">
            <label>信用代码:</label>
            <input id="uniscIdx" name="" class="easyui-textbox"  />
        </div>
        
        <div class="fitem">
            <label>营业执照:</label>
            <input id="regNox" name="" class="easyui-textbox"  />
        </div>
        <!--直接写提交取消的事件不需要在js中绑定-->
        <div style="display: block;margin-top: 20px;text-align: center;">
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-ok'" onclick="inserEntityx()" style="width: 90px">提交</a>
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#winx').dialog('close')" style="width: 90px">取消</a>
        </div>
    </form>
    </div>
    
    <div id="winy" class="easyui-dialog" title="添加有证企业信息"  style="width: 400px; padding: 10px 20px; height: 380px;"
     closed="true" buttons="#dlg-buttons">
 
    <form id="fmy" method="post" action="" style="margin-top: 20px; margin-left: 20px;">
        <div class="fitem">
            <label>企业名称:</label>
            <input id="entNamey" style="" name="" class="easyui-textbox" data-options="required:true" />
        </div>
        <div class="fitem">
            <label>所属区域:</label>
            <input id="areaCodey" name="" class="easyui-combobox" data-options="valueField:'areCode',textField:'areName',url:'getjson'"/>
        </div>
        <div class="fitem">
            <label>所在地址:</label>
            <input id="regAddry" name="" class="easyui-textbox" data-options="required:true"/>
        </div>
 
        <div class="fitem">
            <label>企业类型:</label>
            <input id="enttypey" name="" class="easyui-combobox" data-options="valueField:'entCode',textField:'entName',url:'enttypejson'" />
        </div>
 
        <div class="fitem">
            <label>企业法人:</label>
            <input id="lerepNamey" name="" class="easyui-textbox"  />
        </div>
 
        <div class="fitem">
            <label>联系电话:</label>
            <input id="contTely" name="" class="easyui-textbox"  />
        </div>
        
        <div class="fitem">
            <label>信用代码:</label>
            <input id="uniscIdy" name="" class="easyui-textbox"  />
        </div>
        
        <div class="fitem">
            <label>营业执照:</label>
            <input id="regNoy" name="" class="easyui-textbox"  />
        </div>
        <!--直接写提交取消的事件不需要在js中绑定-->
        <div style="display: block;margin-top: 20px;text-align: center;">
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-ok'" onclick="editEntity()" style="width: 90px">提交</a>
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#winy').dialog('close')" style="width: 90px">取消</a>
        </div>
    </form>
    </div>
	<script type="text/javascript">
		var editIndex = undefined;
		function onClickRow(index){
			if (editIndex != index){
				if (endEditing()){
					$('#dg').datagrid('selectRow', index)
							.datagrid('beginEdit', index);
					editIndex = index;
				} else {
					$('#dg').datagrid('selectRow', editIndex);
				}
			}
		}
		/*添加监管企业信息*/
		function append(){
			$('#win').dialog('open');
		}
		
		function appendx(){
			$('#winx').dialog('open');
		}
		/*修改信息*/
		function accept(){
			var selRow = $('#dg').datagrid('getSelected');
			if(selRow == null){
				$.messager.alert('错误提示','请选中一条数据!','error');
			}else{
				//ajax请求并回显数据
				$('#winy').dialog('open');
			}
			
			
		}
		function removeit(){
			var selRow = $('#dg').datagrid('getSelected');
			if(selRow == null){
				$.messager.alert('错误提示','请选中一条数据!','error');
			}else{
				$.ajax({
					   type: "POST",
					   url: "delscztxx/" + selRow.id,
					   success: function(data){
						   if(data.code===200){
							   $("#dg").datagrid('reload');
						   }
					   }
					});
			}
		}
		function searchGep(){
			var datajosn = { "entName": $("#search").val()}
			$.ajax({
				   type: "GET",
				   url: "scztxx",
				   data: datajosn,
				   success: function(data){
					   $("#dg").datagrid("loadData", data);
				   }
				});
		}
		function inserEntity(){
			var datajosn = { 
					"entName": $("#entName").val(),
					"areaCode": $("#areaCode").combobox("getValue"),
					"regAddr": $("#regAddr").val(),
					"enttype": $("#enttype").combobox("getText"),
					"enttypeCode": $("#enttype").combobox("getValue"),
					"lerepName": $("#lerepName").val(),
					"contTel": $("#contTel").val()
					}
			$.ajax({
				   type: "POST",
				   url: "addscztxx",
				   data: datajosn,
				   success: function(data){
					   console.log(data);
					   debugger
					   if(data.code===200){
						   $('#win').dialog('close');
						   $("#dg").datagrid('reload');
						   $.messager.alert('提示','添加成功!','info');
					   }
				   }
				});
		}
		function inserEntityx(){
			var datajosn = { 
					"entName": $("#entNamex").val(),
					"areaCode": $("#areaCodex").combobox("getValue"),
					"regAddr": $("#regAddrx").val(),
					"enttype": $("#enttypex").combobox("getText"),
					"enttypeCode": $("#enttypex").combobox("getValue"),
					"lerepName": $("#lerepNamex").val(),
					"contTel": $("#contTelx").val(),
					"uniscId": $("#uniscIdx").val(),
					"regNo": $("#regNox").val(),
					}
			$.ajax({
				   type: "POST",
				   url: "addscztxx",
				   data: datajosn,
				   success: function(data){
					   console.log(data);
					   debugger
					   if(data.code===200){
						   $('#winx').dialog('close');
						   $("#dg").datagrid('reload');
						   $.messager.alert('提示','添加成功!','info');
					   }
				   }
				});
		}
	</script>
</body>
</html>